/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package net.tygzs.minerpg.CommandExecutor.MinePacket;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

/**
 *
 * @author thtTNT
 */
public class MinePacket implements CommandExecutor
{

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String args[])
    {
        try
        {
            if (args.length == 0)
            {
                Command_Help.sendHelp(sender, null);
                return true;
            }
            if (args[0].equalsIgnoreCase("help"))
            {
                if (args.length == 2)
                {
                    Command_Help.sendIndexOfHelp(sender, Integer.parseInt(args[1]));
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MinePacket help <页码> 获取关于礼包的帮助");
                return true;
            }
            if (args[0].equalsIgnoreCase("create"))
            {
                if (args.length == 2)
                {
                    Command_Create.CreatePacket(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MinePacket create <礼包名称> 创建一个礼包");
                return true;
            }
            if (args[0].equalsIgnoreCase("edit"))
            {
                if (args.length == 2)
                {
                    Command_Edit.openPacketEditer(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MinePacket edit <礼包名称> 编辑一个礼包");
                return true;
            }
            if (args[0].equalsIgnoreCase("NewPlayer"))
            {
                if (args.length == 2)
                {
                    Command_NewPlayer.ChangeNewPlayer(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW + "/MinePacket NewPlayer <礼包名称> 取消/设置一个新手礼包");
                return true;
            }
            if (args[0].equalsIgnoreCase("list"))
            {
                Command_List.sendList(sender);
                return true;
            }
            if (args[0].equalsIgnoreCase("remove")){
                if (args.length==2){
                    Command_Remove.RemovePacket(sender, args[1]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW+"/MinePacket remove <礼包名称> 删除一个礼包");
                return true;
            }
            if (args[0].equalsIgnoreCase("send")){
                if (args.length==3){
                    Command_Send.SendPacketToPlayer(sender,args[1], args[2]);
                    return true;
                }
                sender.sendMessage(ChatColor.YELLOW+"/MinePacket send <礼包名称> <玩家名称> 赠送指定礼包给玩家");
                return true;
           }
        } catch (NumberFormatException e)
        {
            sender.sendMessage(ChatColor.RED + "请输入正确的数字");
            return true;
        }
        return true;
    }
}
